const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter

// pages/jg_wrongs/jg_wrongs.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    windowWidth:wx.getSystemInfoSync().windowWidth,
  },

  view_ti(e){
    getApp().get_vibration()
    // console.log('view_ti',e)
    let ti_id = e.currentTarget.id
    wx.navigateTo({
      url: '/pages/doTi/show_ti/show_ti?ti_id=' + ti_id,
    })
  },

  // 关闭抽屉
  close_drawer(){
    this.setData({
      show:false,
    })
  },

  // 查看做错该题的学员
  show_whoWrong(e){
    getApp().get_vibration()
    let index = e.currentTarget.id
    let ti_id = this.data.ti_list[index].id
    wx.request({
      url: domainName + '/load_stus_of_wrongTi',
      data: {
        jg_id:this.jg_id,
        ti_id,
        date_set:this.date_set,
      },
      ...parameter,
      success: res => {
        this.setData({
          stu_list:res.data.stu_list,
          show:true,
        })
      },
    })
  },



  // 加载机构今日易错题列表
  load_wrongs_of_jg(jg_id, date_set){
    wx.request({
      url: domainName + '/load_wrongs_of_jg',
      data: {
        jg_id: jg_id,
        date_set: date_set,
      },
      ...parameter,
      success: res => {
        console.log('加载机构今日易错题列表',res.data)
        this.setData({
          ti_list:res.data.ti_list
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let jg_id = options.jg_id
    let date_set = options.date_set
    this.jg_id = jg_id
    this.date_set = date_set
    this.load_wrongs_of_jg(jg_id, date_set)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    this.setData({
      windowHeight:wx.getSystemInfoSync().windowHeight,
    })
  },

})